<template>
  <div class="rated">
    <p class="title">最受好评电影</p>
    <div class="wrapper">
      <ul>
        <li v-for="item in ratedList" :key="item._id">
          <div class="img-wrap">
            <img :src="item.imgUrl" alt="" />
            <div class="shadow" v-if="item.score">
              观众评分:{{ item.score }}
            </div>
            <div class="shadow" v-else>{{ item.wishNum }}人想看</div>
          </div>
          <p class="movie-title">{{ item.title }}</p>
        </li>
      </ul>
    </div>
  </div>
</template>
<script>
import {ratedApi} from '@/api/home.js'
export default {
  data() {
    return {
      ratedList: [],
    };
  },
  mounted() {
    this.getData();
  },
  methods: {
    async getData() {
        //   if (res.status === 0) {
        //     this.ratedList = res.result;
        //   }
      const res=await ratedApi()
      this.ratedList=res.result
    },
  },
};
</script>
<style lang="less" scoped>
.rated {
  width: 100%;
  height: 205px;
  background-color: #fff;
  padding: 12px 15px;
  .title {
    font-size: 14px;
    color: #333;
    margin: 0 0 12px;
  }
  ul {
    width: 100%;
    height: 150px;
    display: flex;
    overflow: auto;
    li {
      width: 85px;
      height: 100%;
      margin-right: 10px;
      flex-shrink: 0;

      .img-wrap {
        width: 85px;
        height: 110px;
        position: relative;
        img {
          width: 100%;
          height: 100%;
        }
        .shadow {
          position: absolute;
          width: 100%;
          height: 30px;
          background: linear-gradient(
            to bottom,
            rgba(0, 0, 0, 0.2),
            rgba(0, 0, 0, 0.8)
          );
          bottom: 0;
          left: 0;
          color: @score-color;
          font-size: @xs-font;
          line-height: 30px;
          text-align: center;
        }
      }
      .movie-title {
        font-size: @s-font;
        font-weight: 900;
        .ell();
        margin-top: 5px;
        text-align: center;
      }
    }
  }
}
</style>
